<extend name="Base/common"/>
<block name="body">
    <div class="span9 page_message">
        <section id="contents">
            <include file="Addons/_nav"/>
            <if condition="$add_button || $del_button || $search_button || !empty($top_more_button)">
                <div class="table-bar">
                    <div class="fl">
                        <empty name="model.extend">
                            <div class="tools">
                                <if condition="$add_button">
                                    <php> $add_url || $add_url = U('add?model='.$model['id'], $get_param);</php>
                                    <a class="btn" href="{$add_url}">新 增</a></if>
                                <if condition="$del_button">
                                    <php> $del_url || $del_url = U('del?model='.$model['id'], $get_param);</php>
                                    <button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除
                                    </button>
                                </if>
                                <volist name="top_more_button" id="vo">
                                    <if condition="$vo[is_buttion]">
                                        <button class="btn {$vo.class}" target-form="ids" url="{$vo.url}">{$vo.title}
                                        </button>
                                        <else/>
                                        <a class="btn" href="{$vo.url}">{$vo.title}</a>
                                    </if>
                                    &nbsp;
                                </volist>
                            </div>
                        </empty>
                    </div>
                    <!-- 高级搜索 -->
                    <form method="post">
                        <div class="search-form fr cf">
                            <div class="sleft">
                                <div class="drop-down">
                                    <input name="list_sort" type="hidden" value="{$list_sort}"/>
                                    <span id="sch-sort-txt" class="sort-txt"><if condition="$list_sort eq 1">按昵称排序
                                        <else/>
                                        按注册时间排序
                                    </if></span>
                                    <i class="arrow arrow-down"></i>
                                    <ul id="sub-sch-menu" class="nav-list hidden">
                                        <li><a href="javascript:;" value="1">按昵称排序</a></li>
                                        <li><a href="javascript:;" value="2">按注册时间排序</a></li>
                                    </ul>
                                </div>
                                <php> $get_param[model]=$model['name']; $search_url || $search_url =
                                    addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists',
                                    $get_param);
                                </php>
                                <php>empty($search_key) && $search_key=$model['search_key'];empty($search_key) &&
                                    $search_key='title';
                                </php>
                                <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}"
                                       placeholder="{$placeholder}">
                                <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i
                                        class="btn-search"></i></a></div>
                        </div>
                    </form>
                </div>
            </if>
            <!-- 数据列表 -->
            <div class="data-table">
                <div class="table-striped">
                    <table cellspacing="1">
                        <!-- 表头 -->
                        <thead>
                        <tr>
                            <if condition="$check_all">
                                <th class="row-selected row-selected"><input type="checkbox" id="checkAll"
                                                                             class="check-all regular-checkbox"><label
                                        for="checkAll"></label></th>
                            </if>
                            <volist name="list_grids" id="field">
                                <th
                                <notempty name="field.width">width="{$field.width}%"</notempty>
                                >{$field.title}</th>
                            </volist>
                        </tr>
                        </thead>

                        <!-- 列表 -->
                        <tbody>
                        <volist name="list_data" id="data">
                            <tr>
                                <if condition="$check_all">
                                    <td><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}"
                                               name="ids[]" id="check_{$data['id']}"><label
                                            for="check_{$data['id']}"></label></td>
                                </if>
                                <volist name="list_grids" id="grid">
                                    <td>{:get_list_field($data,$grid,$model)}</td>
                                </volist>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="page"> {$_page|default=''}</div>
        </section>
    </div>
</block>
<block name="script">
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                /*var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;*/

                $('form').submit();   //自动提交
            });

            /* 状态搜索子菜单 */
            $(".search-form").find(".drop-down").hover(function(){
                $("#sub-sch-menu").removeClass("hidden");
            },function(){
                $("#sub-sch-menu").addClass("hidden");
            });
            $("#sub-sch-menu li").find("a").each(function(){
                $(this).click(function(){
                    var text = $(this).text();
                    $("#sch-sort-txt").text(text);
                    $("input[name='list_sort']").attr("value",$(this).attr("value"));
                    //$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                    $("#sub-sch-menu").addClass("hidden");

                    $('form').submit();   //自动提交
                })
            });

            //回车自动提交
            $('.search-form').find('input').keyup(function (event) {
                if (event.keyCode === 13) {
                    //$("#search").click();
                    $('form').submit();
                }
            });

        })
    </script>
</block>
